package org.phalanx.client.mapeditor;

import java.awt.Color;
import java.awt.FlowLayout;

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class PhalanxMapMetadataPanel extends JPanel {
	private static final long serialVersionUID = 4196638350706949134L;
	private JTextField authorName;
	private JTextField authorEmail;
	private JTextField authorCountry;
	private JTextField authorURL;
	
	public PhalanxMapMetadataPanel() {
		initializePanel();
		setUpComponents();
		setUpPanels();
	}
	
	private void initializePanel() {
		this.setBackground(Color.black);
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
	}
	
	private void setUpComponents() {
		authorName = new JTextField();
		authorName.setColumns(15);
		
		authorEmail = new JTextField();
		authorEmail.setColumns(30);
		
		authorCountry = new JTextField();
		authorCountry.setColumns(15);
		
		authorURL = new JTextField();
		authorURL.setColumns(40);
	}
	
	private void setUpPanels() {
		JPanel p = getPanel();
		
		p.setLayout(new FlowLayout(FlowLayout.LEFT));
		p.add(getJLabel("Author: "));
		p.add(authorName);
		
		this.add(p);
		
		p = getPanel();
		
		p.setLayout(new FlowLayout(FlowLayout.LEFT));
		p.add(getJLabel("Email: "));
		p.add(authorEmail);
		
		this.add(p);
		
		p = getPanel();
		
		p.setLayout(new FlowLayout(FlowLayout.LEFT));
		p.add(getJLabel("Country: "));
		p.add(authorCountry);
		
		this.add(p);
		
		p = getPanel();
		
		p.setLayout(new FlowLayout(FlowLayout.LEFT));
		p.add(getJLabel("Website URL: "));
		p.add(authorURL);
		
		this.add(p);
	}
	
	private JPanel getPanel() {
		JPanel p = new JPanel();
		p.setBackground(Color.black);
		
		return p;
	}
	
	private JLabel getJLabel(String text) {
		JLabel temp = new JLabel();
		temp.setForeground(Color.white);
		temp.setText(text);

		return temp;
	}

	public JTextField getAuthorName() {
		return authorName;
	}

	public JTextField getAuthorEmail() {
		return authorEmail;
	}

	public JTextField getAuthorCountry() {
		return authorCountry;
	}

	public JTextField getAuthorURL() {
		return authorURL;
	}
	
	public void setAuthorName(String name) {
		authorName.setText(name != null ? name : "");
	}
	
	public void setAuthorEmail(String email) {
		authorEmail.setText(email != null ? email : "");
	}
	
	public void setAuthorCountry(String ccy) {
		authorCountry.setText(ccy != null ? ccy : "");
	}
	
	public void setAuthorURL(String URL) {
		authorURL.setText(URL != null ? URL : "");
	}
}
